'''
Created on 2017-6-22

@author: 24253
'''
from flask import Flask
from zs.chart import app
import pygal,pymysql

@app.route('/1233/')
def index():
    try:
        conn=pymysql.connect(
                             host="127.0.0.1",
                             prot=3306,
                             user="root",
                             passwd="zs910826",
                             db="python",
                             charset="utf8"
                             )
    except Exception as e:
        print(e)
    cur=conn.cursor()
    sql="select*from Xiao order by shuliang DESC LIMIT 10"
    cur.execute(sql)
    alldata=cur.fetchall()
    print(alldata) 
    line_chart=pygal.Pie()
    line_chart.title = '销量TOP10 '   
    for rec in alldata:
            #print rec[0], rec[1]
            line_chart.add(rec[5], rec[3])
    cur.close()
    conn.close()   
    return line_chart.render()

